<?php

namespace app\index\controller;

use tian\Session;

class Task extends Base
{
    public function index()
    {
        try {
            $role_id = Session::get('uid');

            $where = [];
            $where[] = ['uid', '=', $role_id];
            $where[] = ['rwzt', '<>', 3];
            $list = model('RoleTask')->getList($where);
			if(!empty($list)){
				foreach($list as $k=>$vo){
					$vo['rwlxName'] = $vo['rwlx'] == 1 ? "普通" : ($vo['rwlx'] == 2 ? '每日' : '主线');
					$vo['rwzlName'] = $vo['rwzl'] == 1 ? "收集" : ($vo['rwzl'] == 2 ? '打怪' : '对话');

					$vo['rwyq_name'] = '';
					$vo['rwcount_name'] = '';
					if ($vo['rwzl'] == 1) {//收集
						$vo['rwyq_name'] = model('Prop')->findValue(['djid' => $vo['rwyq']], 'djname');
					}
					if ($vo['rwzl'] == 2) {//打怪
						$vo['rwyq_name'] = model('Monster')->findValue(['id' => $vo['rwyq']], 'gname');
					}					
					if ($vo['rwzl'] == 3) {//对话
						$vo['rwyq_name'] = model('Npc')->findValue(['id' => $vo['rwyq']], 'nname');
						$vo['rwcount_name'] = model('Npc')->findValue(['id' => $vo['rwcount']], 'nname');
					}
				}
			}
            $this->assign('list', $list);

            $this->fetch('index');
        } catch (\Throwable $e) {
            echo $e->getMessage();
        }
    }

    
}
